﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Facer
{
    public partial class FormMain : Form
    {
        public FormMain()
        {
            InitializeComponent();
        }

        private void FormMain_Load(object sender, EventArgs e)
        {
            listViewOverView.FullRowSelect = true;

        }

        private void listViewOverView_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.All;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

        private void listViewOverView_DragDrop(object sender, DragEventArgs e)
        {
            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop, false);

            foreach(string filePath in files)
            {
                FileInfo fileInfo = new FileInfo(filePath);
                if ((fileInfo.Attributes & FileAttributes.Directory) != 0)
                {
                    toolStripStatusLabelMsg.Text = "请直接拖入文件";
                    continue;
                }
                ListViewItem item = new ListViewItem();
                //序号
                item.SubItems.Add((listViewOverView.Items.Count + 1).ToString());
                //文件名
                item.SubItems.Add(Path.GetFileName(filePath));
                //预览
                item.SubItems.Add(Path.GetFileName(filePath));
                //拓展名
                item.SubItems.Add(Path.GetExtension(filePath));
                //文件信息
                float size = fileInfo.Length/1024.0f/1024.0f;
                //文件大小
                item.SubItems.Add(String.Format("{0:F2}M",size));
                //上次修改日期
                item.SubItems.Add(fileInfo.LastWriteTime.ToString("yyyy-MM-dd"));
                //路径
                item.SubItems.Add(filePath);
                

                listViewOverView.Items.Add(item);
            }
        }
    }
}
